package com.vincent.common.utils;

import java.util.Random;

/**
 * Created by vincent on 11/3/14.
 */
public class RandomCharUtil {

    private static final String []codes={"A","B","C","D","E","F","G","H","J","K","L","M","N","P","Q","R","S","T","U","V","W","X","Y","Z",
            "a","b","c","d","e","f","g","h","j","k","l","m","n","p","q","r","s","t","u","v","w","x","y","z","2","3","4","5","6","7","8","9"};

    /**
     * 获取随机数
     * @param num 数目
     * @return
     */
    public static String getRandom(int num){
        StringBuilder sb=new StringBuilder();
        int length = codes.length;
        Random random = new Random();
        for(int i=0;i<num;i++){
            int nextInt = random.nextInt(length);
            String code = codes[nextInt];
            sb.append(code);
        }

        return sb.toString();
    }

}
